package org.example.controller;

import org.example.entity.Inventory;
import org.example.param.InventoryParam;
import org.example.service.InventoryService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.Map;

@RestController
@RequestMapping("/inventory")
public class InventoryController {
    @Resource
    InventoryService inventoryService;

    @PostMapping("/in")
    public Map<String, Object> in(Inventory inventory) {
        return inventoryService.in(inventory);
    }
    @PostMapping("/out")
    public Map<String, Object> out(Inventory inventory) {
        return inventoryService.out(inventory);
    }
    //in + out 或 change
    @PostMapping("/change")
    public Map<String, Object> change(Inventory inventory) {
        return inventoryService.change(inventory);
    }
    @GetMapping("/page")
    public Map<String,Object> page(InventoryParam param) {
        return inventoryService.page(param);
    }
    @PostMapping("/delete")
    public Map<String, Object> delete(Inventory inventory) {
        return inventoryService.delete(inventory);
    }
    @PostMapping("/batch-import")
    public Map<String, Object> batchImport(MultipartFile file) {
        return inventoryService.importExcel(file);
    }
}